<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	template="/templates/template_basic.xhtml">
	<ui:define name="title">
		#{msgs['home.title']}
	</ui:define>
	<ui:define name="content">
		<h:form id="loadForm" enctype="multipart/form-data">
			<p:growl id="messages" showDetail="true" sticky="true" />
			<h:panelGrid columns="1">
				<p:outputLabel value="#{msgs['load.title']}" />
				<p:fileUpload fileUploadListener="#{loadBean.handleFileUpload}"
					mode="advanced" update="loadForm:messages,loadForm:documents" multiple="true"
					sizeLimit="10000000" allowTypes="/(\.|\/)(pdf|txt|doc|docx)$/"
					label="#{msgs['load.label.choose']}"
					uploadLabel="#{msgs['load.label.upload']}"
					cancelLabel="#{msgs['load.label.cancel']}" />
			</h:panelGrid>
			<h:panelGrid columns="1">
				<p:outputLabel value="#{msgs['load.controls.classifydocuments']}" />
				<p:commandButton value="#{msgs['load.controls.classify']}"
					actionListener="#{loadBean.classify}" update="loadForm:messages,loadForm:documents" />
			</h:panelGrid>
			<h:panelGrid id="gridDocuments" columns="2">
				<p:dataTable id="documents" value="#{loadBean.documentsModel}" var="doc"
					paginator="true" rows="5" paginatorAlwaysVisible="true" paginatorPosition="top"
					selection="#{loadBean.selectedDoc}" selectionMode="single">
  
			        <p:ajax event="rowSelect" listener="#{loadBean.onRowSelect}"
			                    update=":templateBodyForm:loadForm:gridDocuments"/>  

					<f:facet name="header">  
		                #{msgs['load.label.documents']}  
		            </f:facet>
  
			        <p:column>  
			            #{doc.shortName}
			        </p:column>
        		</p:dataTable>
					<p:barChart id="basic1" value="#{loadBean.categoryModel}"
						title="#{msgs['train.controls.results']}" legendPosition="ne"
						style="width:400px;height:200px;" animate="true" min="0" max="100" />
			</h:panelGrid>
		</h:form>
	</ui:define>
</ui:composition>